$(function () {
    //等待加载
    loading();
    var devId = getQueryString("devId");
    ajaxdeveloperDetails(devId, 1);
    oversize("productName",18);
})
/**
 * 查看内容商（详情） （已关注）
 *
 * @param devId 内容商Id
 * @param page 当前页数
 * @returns
 */
function confirmBox(contenterID){
    $(".mask").show();
    $(".confirmBox").show();
    $(".unCare").click(function(){
        $(".confirmBox").hide();
        ajaxDeleteDeveloper(contenterID);
    })
}
function ajaxdeveloperDetails(devId, page) {
    var url = "/Lvscore_User_M/myAds/ajaxdeveloperDetails";
    $.post(url, {
        devId: devId,
        page: page
    }, function (data) {
        // sumpage：页容量（页面的数据条数）
        // nowpage：页码
        // developer：DeveloperBean
        // id:内容商id
        // donkey_num: 小毛驴id
        // company_name: 公司名称
        // company_address: 公司地址
        // description:产品介绍
        // developer_Ads_videoList：List<DeveloperAdsDto>
        // ad_id: 广告Id
        // ad_name: 广告名称
        // ad_type: 广告类型
        // duration: 广告时常
        // picture_num: 广告张数
        // pc_size: 广告大小
        // adv_url: 广告路径
        // delivery_price: 投放单价
        // plan_end: 投放时间
        // play_num: 广告播放数量

        // developer_Ads_pictureList：List<DeveloperAdsDto>
        // ad_id: 广告Id
        // ad_name: 广告名称
        // ad_type: 广告类型
        // picture_num: 广告张数
        // pc_size: 广告大小
        // adv_url: 广告路径
        // delivery_price: 投放单价
        // plan_end: 投放时间
        // play_num: 广告播放数量

        // applicationList：List<ApplicationNewBean>
        // id:应用id
        // name:应用名
        // price:应用价格
        // devId:内容商id
        // logourl:logo图片地址
        // classify: 分类
        // longdesc:长描述
        // versionCode：资源版本号
        // downloadurl：下载地址
        // downloadTimes：下载次数
        //已关注的内容商
    	if(!isNotEmpty(data.developer.logo)){
    		data.developer.logo="/Lvscore_User_M/userWeb/static/images/manageWrap_pic.png";
    	};
    	if(data.developer.company_address==null || data.developer.company_address==""){
    		data.developer.company_address="无";
    	};
        $("#name1").append("<img src='"+data.developer.logo+"' width='90px' alt='' class='left'>" +
            "<div class='left marginLeft'>" +
            "<div class='right handes addContenter deletContenter' onclick='confirmBox(" + data.developer.id + ")'> " +
            "取消关注" +
            "</div>" +
            "<a href='/Lvscore_User_M/userWeb/views/ADadmin/payment/contenter.html?devId="+data.developer.id+"'>"+
            "<div class='right handes addContenter payToContenter'>" +
            "向内容商转账" +
            "</div>" +
            "</a>"+
            "<p><label>会员名</label>&nbsp;:&nbsp;<span class='userName'>" + data.developer.company_name + "</span></p>" +
            "<p><label>小毛驴号</label>&nbsp;:&nbsp;<span class='accounterNo'>" + data.developer.donkey_num + "</span></p>" +
            "<p><label>地区</label>&nbsp;:&nbsp;<span class='area'>" + data.developer.company_address + "</span></p>" +
            "</div>");
        if (data.applicationList.length != 0) {
            $("#application").empty();
            $("#application1").prepend("<p>应用文件<a href='/Lvscore_User_M/userWeb/views/myAD/myContenter/AddedApplication.html?devId=" + getQueryString("devId") + "&ad_type=a' title='' alt='' class='right'>更多</a></p>");
            $.each(data.applicationList, function (index, element) {
            	if(!isNotEmpty(element.logourl)){
    				element.logourl="/Lvscore_User_M/userWeb/static/images/bm.png";
    	    	}
                $("#application").append(
                    "<div class='application inline-block'>" +
                    "<p class='appTag'>" + element.classify + "</p>" +
                    "<img src='"+ element.logourl + "'  width='350px' height='200px' alt=''>" +
                    "<div class='botmask'>" +
                    "<p class='appName'>" + element.name + "</p>" +
                    "<p class='appIfo'>" + element.longdesc + "</p>" +
                    "</div>" +
                    "</div>"
                );
                $(".recommendBox ul li").hover(function () {
                    $(this).find(".backdrop").show();
                }, function () {
                    $(this).find(".backdrop").hide();
                });
            });
        }
        if (data.developer_Ads_videoList.length != 0) {
            $("#void").empty();
            $("#void1").prepend(
                "<p>视频广告<a href='/Lvscore_User_M/userWeb/views/myAD/myContenter/AddedVedioAD.html?devId=" + getQueryString("devId") + "&ad_type=v' title='' alt='' class='right'>更多</a></p>");
            $.each(data.developer_Ads_videoList, function (index, element) {
            	if(!isNotEmpty(element.ad_homepage)){
    				element.ad_homepage="/Lvscore_User_M/userWeb/static/images/bm.png";
    	    	}
            	if(!isNotEmpty(element.play_num)){
            		element.play_num=0;
            	}
                $("#void").append(
                    "<li>" +
                    "<span class='hintbg'></span>" +
                    "<span class='center'><span class='productName'>" + element.ad_name + "</span><b><img src='/Lvscore_User_M/userWeb/static/images/recommend_icon.png' alt='' title=''>" + parseFloat(element.delivery_price) .toFixed(2) + "</b></span>" +
                    "<img src='"+element.ad_homepage+"' class='bjHover'>" +
                    "<div class='backdrop'>" +
                    "<div class='bj'></div>" +
                    "<h2>" + element.ad_name + "</h2>" +
                    "<p>有效期至：" + element.plan_end + "</p>" +
                    "<i>" + element.duration + "</i>" +
                    "<ol>" +
                    "<li><span><img src='/Lvscore_User_M/userWeb/static/images/recommend_icon.png'></span>" + parseFloat(element.delivery_price).toFixed(2) + "</li>" +
                    "<li><span><img src='/Lvscore_User_M/userWeb/static/images/recommend_icon3.png'></span>" + element.play_num + "次</li>" +
                    "</ol>" +
                    "<input type='button' ad_type='video' ad_id='" + element.id + "' value='播放' class='plays'>" +
                    "</div>" +
                    "</li>"
                );
                $(".recommendBox ul li").hover(function () {
                    $(this).find(".backdrop").show();
                }, function () {
                    $(this).find(".backdrop").hide();
                });
            });
        }

        if (data.developer_Ads_pictureList.length != 0) {
            $("#pics").empty();
            $("#pics1").prepend("<p>图片广告<a href='/Lvscore_User_M/userWeb/views/myAD/myContenter/AddedPicAD.html?devId=" + getQueryString("devId") + "&ad_type=p' title='' alt='' class='right'>更多</a></p>");
            $.each(data.developer_Ads_pictureList, function (index, element) {
            	if(!isNotEmpty(element.ad_homepage)){
    				element.ad_homepage="/Lvscore_User_M/userWeb/static/images/bm.png";
    	    	}
            	if(!isNotEmpty(element.picture_num)){
            		element.picture_num=0;
            	}
            	if(!isNotEmpty(element.play_num)){
            		element.play_num=0;
            	}
                $("#pics").append(
                    "<li>" +
                    "<span class='hintbg'></span>" +
                    "<span class='center'><span class='productName'>" + element.ad_name + "</span><b> <img src='/Lvscore_User_M/userWeb/static/images/recommend_icon.png' alt='' title=''>" + parseFloat(element.delivery_price).toFixed(2) + "</b></span>" +
                    "<img src='"+element.ad_homepage+"' class='bjHover'>" +
                    "<div class='backdrop'>" +
                    "<div class='bj'></div>" +
                    "<h2>" + element.ad_name + "</h2>" +
                    "<p>有效期至：" + element.plan_end + "</p>" +
                    "<i>" + element.picture_num + "张</i>" +
                    "<ol>" +
                    "<li><span><img src='/Lvscore_User_M/userWeb/static/images/recommend_icon.png'></span>" + parseFloat(element.delivery_price).toFixed(2) + "</li>" +
                    "<li><span><img src='/Lvscore_User_M/userWeb/static/images/recommend_icon2.png'></span>" + element.picture_num + "张</li>" +
                    "<li><span><img src='/Lvscore_User_M/userWeb/static/images/recommend_icon3.png'></span>" + element.play_num + "次</li>" +
                    "</ol>" +
                    "<input type='button' ad_type='pic' ad_id='" + element.id + "' value='播放' class='plays'>" +
                    "</div>" +
                    "</li>");
                $(".recommendBox ul li").hover(function () {
                    $(this).find(".backdrop").show();
                }, function () {
                    $(this).find(".backdrop").hide()
                });

            });
        }
        playAd();
        //等待加载的效果消失
        $(".loadingBox").hide();
    }, "json");

}